import { createSlice, PayloadAction } from "@reduxjs/toolkit";

interface CartState {
  num: number;
}

const initialState: CartState = {
  num: 0
};

const cart = createSlice({
  name: "cart",
  initialState,
  reducers: {
    addcart(state) {
      state.num += 1;
    },
    setCartCount(state, action: PayloadAction<number>) {
      state.num = action.payload;
    }
  }
});

export const { addcart, setCartCount } = cart.actions;
export default cart.reducer; 